package ws.jdbc.concurrent.driver.sqlserver;

import java.sql.Date;
import java.sql.Statement;
import java.sql.SQLException;
import ws.jdbc.concurrent.driver.sqlserver.tds.TDSMessage;
import static ws.jdbc.concurrent.driver.sqlserver.tds.rpc.StoredProcedures.*;

/**
 * Scrollable and read-only result set.
 * 
 * @author Wilson Santos, 36228 <wilson.santos@ua.pt>
 */
public class CResultSetScrollableReadOnly extends CResultSet {

  protected CResultSetScrollableReadOnly(TDSMessage message, Statement stmt) throws SQLException {
    super(message, stmt);
  }

  protected CResultSetScrollableReadOnly(TDSMessage message, Statement stmt, String sql) throws SQLException {
    this(message, stmt);

    tdsResultSet = message.cursorOpen(sql, SP_CURSOROPEN_SCROLLOPT_KEYSET, SP_CURSOROPEN_CCOPT_READ_ONLY);
    lastRow.set(message.cursorRows());
  }

  // <editor-fold defaultstate="collapsed" desc="Operations not supported by read-only result set.">
  @Override
  public void cancelRowUpdates() throws SQLException {
    throw new SQLException(Messages.msg_read_only);
  }

  @Override
  public void moveToCurrentRow() throws SQLException {
    throw new SQLException(Messages.msg_read_only);
  }

  @Override
  public void moveToInsertRow() throws SQLException {
    throw new SQLException(Messages.msg_read_only);
  }

  @Override
  public void updateDate(int columnIndex, Date x) throws SQLException {
    throw new SQLException(Messages.msg_read_only);
  }

  @Override
  public void updateDouble(int columnIndex, double x) throws SQLException {
    throw new SQLException(Messages.msg_read_only);
  }

  @Override
  public void updateInt(int columnIndex, int x) throws SQLException {
    throw new SQLException(Messages.msg_read_only);
  }

  @Override
  public void updateString(int columnIndex, String x) throws SQLException {
    throw new SQLException(Messages.msg_read_only);
  }

  @Override
  public void insertRow() throws SQLException {
    throw new SQLException(Messages.msg_read_only);
  }

  @Override
  public void updateRow() throws SQLException {
    throw new SQLException(Messages.msg_read_only);
  }

  @Override
  public void deleteRow() throws SQLException {
    throw new SQLException(Messages.msg_read_only);
  }

  @Override
  public boolean rowDeleted() throws SQLException {
    throw new SQLException(Messages.msg_read_only);
  }
  // </editor-fold>
}
